/**
 * MarioItem
 * @extends Actor
 * @version 2010.12.04
 */

class MarioItem extends GamePawn abstract;

var bool bFlee;
var Vector myVelocity;

/**
 * PostBeginPlay
 * @version 2010.12.04
 */
simulated function PostBeginPlay() 
{
	Super.PostBeginPlay();

	//Clinton - not sure why this doesn't just pick it up from defaultproperties...

	myVelocity.X = 300.0;
	myVelocity.Y = 100.0;
	myVelocity.Z = 50.0;
	SetCollisionType(COLLIDE_TouchAll);
	SetPhysics(PHYS_Falling);
}




/**
 * DoItemEffect - "abstract" method that should be implemented by subclasses
 * @version 2010.12.04
 */
function DoItemEffect(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal) { }


auto state Patrolling {
	event Timer()
	{
		//`log("MarioItem Location:"$Location);
	}

	simulated event Tick( float DeltaTime )
	{
		Velocity.X = myVelocity.X;
		Velocity.Y = myVelocity.Y;
	}

	/**
	* Touch - uses Template Method to delegate effect behavior to subclasses
	 * @version 2010.12.04
	 */
	event Touch(Actor Other, PrimitiveComponent OtherComp, vector HitLocation, vector HitNormal)
	{
		//Debugging
		`log("Touched: " $Other);
	
	
		if (!Other.bWorldGeometry && Pawn(Other).IsPlayerPawn()) 
		{
			Super.Touch(Other, OtherComp, HitLocation, HitNormal);
			DoItemEffect(Other, OtherComp, HitLocation, HitNormal);
			Destroy();
	
		}
	}

	simulated event HitWall(vector normal, actor wall, PrimitiveComponent wallComp)
	{
		super.HitWall(normal, wall, wallComp);
		//`log("Hit Wall! "$normal);
		if (round(normal.Z) != 1.0) {
			if (abs(round(normal.X)) == 1) {
				myVelocity.X = myVelocity.X * -1;
			}
			if (abs(round(normal.Y)) == 1) {
				myVelocity.Y = myVelocity.Y * -1;
			}
			//`log("reflect, new velocity: "$myVelocity);
		}
	}
	event Bump(Actor Other, PrimitiveComponent OtherComp, vector HitNormal) 
	{
		super.Bump(Other, OtherComp, HitNormal);
		`log("Bumped something");
	}
	event Landed (Object.Vector HitNormal, Actor FloorActor) {
		super.Landed(HitNormal, FloorActor);
		SetPhysics(PHYS_Flying);
	}
}



defaultproperties
{	
	Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
		ModShadowFadeoutTime        = 0.25
		MinTimeBetweenFullUpdates   = 0.20
		AmbientGlow                 = (R = .01, G = .01, B = .01, A = 1.0)
		AmbientShadowColor          = (R = .15, G = .15, B = .15)
		LightShadowMode             = LightShadow_ModulateBetter
		ShadowFilterQuality         = SFQ_High
		bSynthesizeSHLight          = TRUE
    End Object
	Components.Add(MyLightEnvironment)

	Begin Object Class=StaticMeshComponent Name=StaticMeshComponent0
		LightEnvironment = MyLightEnvironment
	End Object
	Components.Add(StaticMeshComponent0);

	Begin Object Name=CollisionCylinder
		CollisionRadius=+0020.000000
		CollisionHeight=+0010.000000
	End Object
	Components.add(CollisionCylinder)

	CollisionComponent  = StaticMeshComponent0;
	CollisionType       = COLLIDE_TouchAll;

	//bFlee               = TRUE;
	//bRotate             = FALSE;
	//bCollideWorld       = TRUE;
	//bCollideComplex     = TRUE;
	//bBlockActors        = FALSE;

	bFlee = true;
	bRotate = false;
	bCollideWorld=true;
	bDirectHitWall=false;
	bCollideComplex=true;
	bBlockActors=false;
}




